﻿//https://leetcode.cn/problems/reverse-only-letters/

class Solution {
public:
    string reverseOnlyLetters(string s)
    {
        int left = 0, right = s.size() - 1;

        while (left < right)
        {
            //不为英文的跳过
            while (left < right && !isalpha(s[left]))
            {
                left++;
            }
            while (left < right && !isalpha(s[right]))
            {
                right--;
            }
            swap(s[left++], s[right--]);

        }
        return s;
    }
};